package com.iqiyi.dbagent.base.filecenter;

import java.io.IOException;


public class FileTest {

    public void writeFile() throws IOException, InterruptedException {

        System.out.println(FileUtil.currentWorkDir);

        StringBuilder sb = new StringBuilder();

        long originFileSize = 1024 * 1024 * 10;// 100M
        int blockFileSize = 1024 * 1024 * 1;// 15M

        // ���һ�����ļ�
        for (int i = 0; i < originFileSize; i++) {
            sb.append("A");
        }

        String fileName = FileUtil.currentWorkDir + "origin.myfile";
        //System.out.println(fileName);
        //System.out.println(FileUtil.write(fileName, sb.toString()));

        // ׷������
        //sb.setLength(0);
        //sb.append("0123456789");
        FileUtil.append(fileName, sb.toString());

        FileUtil fileUtil = new FileUtil();

        // ��origin.myfile���
        fileUtil.splitBySize(fileName, blockFileSize);

        Thread.sleep(10000);// �Ե�10�룬��ǰ���С�ļ�ȫ��д��

        // �ϲ������ļ�
        fileUtil.mergePartFiles(FileUtil.currentWorkDir, ".part",
                blockFileSize, FileUtil.currentWorkDir + "new.myfile");

    }
}